   <?php
   if (isset($_POST['lastname']))
    {
        $entreprise = new Entreprise();
        // variable qui va nous servir pour savoir s'il y a a eu une erreur ;)
        $form = true;
        $errMSG = array();


        /* --------------------- INFORMATIONS ----------------------- */
        if (isset($_POST['lastname']) && !empty($_POST['lastname']))
        {
            $tmp = $entreprise->setNomEntreprise($_POST['lastname']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['nom'] = $tmp['errmsg'];
                $form = false;
            }
        }

        if (isset($_POST['description']) && !empty($_POST['description']))
        {
            $tmp = $entreprise->setDescriptionEntreprise($_POST['description']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['description'] = $tmp['errmsg'];
                $form = false;
            }
        }
        /* ------------------ FIN INFORMATIONS --------------------- */

        /* ----------------------- CONTACT ------------------------- */
        if (isset($_POST['email']) && !empty($_POST['email']))
        {
            $tmp = $entreprise->setMailEntreprise($_POST['email']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['mail'] = $tmp['errmsg'];
                $form = false;
            }
        }

        if (isset($_POST['tel']) && !empty($_POST['tel']))
        {
            $tmp = $entreprise->setTelephoneEntreprise($_POST['tel']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['tel'] = $tmp['errmsg'];
                $form = false;
            }
        }

        if (isset($_POST['site']) && !empty($_POST['site']))
        {
            $tmp = $entreprise->setSiteEntreprise($_POST['site']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['site'] = $tmp['errmsg'];
                $form = false;
            }
        }
        /* -------------------- FIN CONTACT ----------------------- */

        /* ----------------------- ADRESSE ------------------------ */
        if (isset($_POST['adresse']) && !empty($_POST['adresse']))
        {
            $tmp = $entreprise->setAdresse1Entreprise($_POST['adresse']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['add1'] = $tmp['errmsg'];
                $form = false;
            }
        }
        if (isset($_POST['adresse2']) && !empty($_POST['adresse2']))
        {
            $tmp = $entreprise->setAdresse2Entreprise($_POST['adresse2']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['add2'] = $tmp['errmsg'];
                $form = false;
            }
        }
        if (isset($_POST['city']) && !empty($_POST['city']))
        {
            $tmp = $entreprise->setVilleEntreprise($_POST['city']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['ville'] = $tmp['errmsg'];
                $form = false;
            }
        }
        if (isset($_POST['cp']) && !empty($_POST['cp']))
        {
            $tmp = $entreprise->setCPEntreprise($_POST['cp']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['cp'] = $tmp['errmsg'];
                $form = false;
            }
        }

        if (isset($_POST['zone']) && !empty($_POST['zone']))
        {
            $tmp = $entreprise->setIdZone($_POST['zone']);
            if ($tmp['boolOk'] === false)
            {
                $errMSG['zone'] = $tmp['errmsg'];
                $form = false;
            }
        }
        /* -------------------- FIN ADRESSE ----------------------- */

        if ($form === true)
        {
            $entreprise->insertEntreprise();
            echo $entreprise->Id;
        }
    }
    ?>